#{extends 'main.html' /}

<div class="row">
<div class="col-sm-3"></div>
<div class=" nav-tabs box-div col-sm-6" style="margin-top:40px;margin-bottom: 40px;">
	<form class="form-horizontal" id="defaultForm"  action="@{UserSecures.saveUser}" method="post" role="form" enctype="multipart/form-data">
		<legend>账号申请</legend>	
		已有账号？<a href="@{Application.login}"  >登陆</a>
		<p class="btn-success">${flash.backMessage }</p>	
		<fieldset>
		<input type="hidden" name="user.type" value="1">
		<input type="hidden" name="user.status" value="1">      
		<div class="form-group">
		    <label class="col-sm-2 control-label" for="user.account">账号</label>
		    <div class="col-sm-5">
		        <input type="text" class="form-control" name="user.account"   required="required" value="${flash.account }"   placeholder="请输入账号" >          
		    </div>
		</div>
		<div class="form-group">
		    <label class="col-sm-2 control-label" for="user.password">密码</label>
		    <div class="col-sm-5">
		        <input  class="form-control" type="password" name="user.password" required="required" value=""    placeholder="请输入密码" >          
		    </div>
		</div>
		<div class="form-group">
		    <label class="col-sm-2 control-label" >确认密码</label>
		    <div class="col-sm-5">
		        <input  class="form-control" type="password" name="confirmPassword" required="required"  value=""    placeholder="请再次输入密码" >          
		    </div>
		</div>
		<div class="form-group">
		    <label class="col-sm-2 control-label" for="user。rname">真实姓名</label>
		    <div class="col-sm-5">
		        <input type="text" class="form-control" name="user.rname" required="required" value="${flash.rname }"  placeholder="请输入真实姓名" >              
		    </div>
		</div>
		<div class="form-group">
		    <label class="col-sm-2 control-label" for="user.prc" >身份证</label>
		    <div class="col-sm-5">
		        <input type="text" class="form-control" name="user.prc" required="required" value="${flash.prc }" value="" maxlength="18"    placeholder="请输入身份证" >              
		    </div>
		</div>
		<div class="form-group">
		    <label class="col-sm-2 control-label" for="user.email" >邮箱</label>
		    <div class="col-sm-5">
		        <input type="text" class="form-control" name="user.email" required="required" value="${flash.email }"   placeholder="请输入邮箱" >              
		    </div>
		</div>
		<div class="form-group">
		    <label class="col-sm-2 control-label" for="user.sex">性别</label>
		    <div class="col-sm-5 btn-default" >
		        <select name="user.sex"   >
		            <option value="1" ${flash.sex==1?'':'checked' } >男</option>
		            <option value="2" ${flash.sex==2?'':'checked' } >女</option>
		        </select>
		        
		    </div>
		</div>
		<div class="form-group">
		    <label class="col-sm-2 control-label" for="user.birthday">出生日期</label>
		    <div class="col-sm-5">
		        <input type="date" class="form-control" name="user.birthday" required="required" value="${flash.birthday }"    placeholder="请输入出生年月 如：1996/08/02" >          
		    </div>
		</div>
		<div class="form-group">
		    <label class="col-sm-2 control-label" for="photo">个人头像</label>
		    <div class="col-sm-5">
		        <input  class="form-control" type="file" name="photo" required="required" onChange="checkImgType(this)">
		    </div>
		
		</div>
		<div class="form-group">
		            <div class="col-sm-4 control-label">
		                <button type="submit"  class="btn btn-success">注册</button>
		                <button type="reset" class="btn btn-default" id="resetBtn">重置</button>
		            </div>
		</div>
		</fieldset>
</form>	
</div>
</div>



#{set 'moreScripts'}
<script type="text/javascript">
$(document).ready(function() {
    // Generate a simple captcha
    function randomNumber(min, max) {
        return Math.floor(Math.random() * (max - min + 1) + min);
    };
    $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));

    $('#defaultForm').bootstrapValidator({
//        live: 'disabled',
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            username: {
                message: '无效的用户名',
                validators: {
                    notEmpty: {
                        message: '用户名不能为空',
                    },
                    stringLength: {
                        min: 4,
                        max: 12,
                        message: '用户名长度需为4到12个字符',
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: '用户名只能是数字和字母'
                    },
                   
                    different: {
                        field: 'password',
                        message: '用户名和密码不能相同'
                    }
                }
            },
            'user.account': {
                message: '无效的用户名',
                validators: {
                    notEmpty: {
                        message: '用户名不能为空',
                    },
                    stringLength: {
                        min: 4,
                        max: 12,
                        message: '用户名长度需为4到12个字符',
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: '用户名只能是数字和字母'
                    }
                }
            },
          'user.prc': {
                message: '无效的用户名',
                validators: {
                    notEmpty: {
                        message: '身份证不能为空',
                    },
                    stringLength: {
                        min: 18,
                        max: 18,
                        message: '身份证长度需为18个字符',
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: '身份证只能是数字和字母'
                    }


                }
            },
            
            'user.rname': {
                validators: {
                	 notEmpty: {
                         message: '真实姓名不能为空',
                     }                   
                }
            },
            
            'user.email': {
                validators: {
                	 notEmpty: {
                         message: '邮箱不能为空',
                     },
                    emailAddress: {
                        message: '邮箱格式不正确'
                    }
                }
            },
            
            pass: {
                validators: {
                    notEmpty: {
                        message: '密码不能为空'
                    },
                    stringLength: {
                        min: 4,
                        max: 12,
                        message: '密码需为4到12个字符',
                    },
                    different: {
                        field: 'username',
                        message: '密码和用户名不能相同'
                    }
                }
            },
          'user.password': {
                validators: {
                    notEmpty: {
                        message: '密码不能为空'
                    },
                    stringLength: {
                        min: 4,
                        max: 12,
                        message: '密码需为4到12个字符',
                    },
                    different: {
                        field: 'user.account',
                        message: '密码和用户名不能相同'
                    },
                    identical: {
                        field: 'confirmPassword',
                        message: '两次密码输入不同'
                    }
                }
            },
            confirmPassword: {
                validators: {
                    notEmpty: {
                        message: '请再次输入密码'
                    },
                    identical: {
                        field: 'user.password',
                        message: '两次密码输入不同'
                    }
                }
            },
            'user.birthday': {
                validators: {
                	 notEmpty: {
                         message: '出生日期不能为空',
                     },
                    date: {
                        format: 'YYYY-MM-DD',
                        message: '无效的出生日期'
                    }
                }
            },
            'user.sex': {
                validators: {
                    notEmpty: {
                        message: '请选择性别'
                    }
                }
            }
          
        }
    });

    // Validate the form manually
    $('#validateBtn').click(function() {
        $('#defaultForm').bootstrapValidator('validate');
    });

    $('#resetBtn').click(function() {
        $('#defaultForm').data('bootstrapValidator').resetForm(true);
    });
});
</script>
#{/set}


